<cfcomponent>

	<cfscript>
		this.name = "Wrapper";
		this.clientManagement = false;
		this.loginStorage = "cookie";
		this.sessionManagement = false;
		this.applicationTimeout = CreateTimeSpan(100,0,0,0);
		this.datasource = "WMS";
        // this.mappings["/assets"] = "C:\inetpub\assets";
		// this.mappings["/validateThis"] = "C:\inetpub\assets\validateThis";
		// StructInsert(this.mappings, "/validateThis", "C:\inetpub\assets\validateThis");
	</cfscript>
	
	<cffunction name="onApplicationStart">
		<cfscript>
			if (cgi.HTTP_HOST eq "calgrants"){
				application.mode = "dev";
				
			} else {
				application.mode = "prod";
			}
			application.pathToApplication = "/wseval";
			application.pathToJQuery = "/assets/jquery/jquery.min.js";
			application.pathToJQueryUI = "/assets/jquery/jquery-ui.min.js";
			application.pathToJQueryMobile = "/assets/jquery/jquery.mobile-1.1.1.min.js";
			application.pathToJQueryMobileCSS = "/assets/jquery/jquery.mobile-1.1.1.min.css";
			application.pathToKendo = "/assets/kendoui/js/kendo.all.min.js";
			application.pathToKendoDefaultCSS = "/assets/kendoui/styles/kendo.default.min.css";
			application.pathToKendoCommonCSS = "/assets/kendoui/styles/kendo.common.min.css";
			application.pathToBootstrap = "/assets/bootstrap/js/bootstrap.min.js";
			application.pathToBootstrapCSS = "/assets/bootstrap/css/bootstrap-combined.min.css";
			application.pathToComponents = "assets.calgrants.com";
			application.pathToBO = application.pathToComponents & ".bo";
			application.pathToServices = application.pathToComponents & ".service";
			application.pathToGateways = application.pathToComponents & ".gateway";
			application.pathToUI = "/assets/calgrants/ui";
			//application.bootstrapCDNUrl = "//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js";
			//application.bootstrapCSSCDNUrl = "//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css";
			//application.jQueryCDNUrl = "//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
			//application.jQueryUICDNUrl = "//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js";
			//application.kendoCDNUrl = "//da7xgjtj801h2.cloudfront.net/2012.2.710/js/kendo.all.min.js";
			//application.kendoCommonCSSCDNUrl = "//cdn.kendostatic.com/2012.2.710/styles/kendo.common.min.css";
   			//application.kendoDefaultCSSCDNUrl = "//cdn.kendostatic.com/2012.2.710/styles/kendo.default.min.css";
			application.apiUrl = "/assets/calgrants/com/API.cfc";
			application.personality = {};
			application.personality.name = "Cash for College";
			application.personality.email = "cashforcollege@csac.ca.gov";
			application.personality.bcc = "cash4collegeca@gmail.com";
			application.personality.phone = "916-464-6410";
			application.developer = {};
			application.developer.name = "Syntric";
			application.developer.email = "support@syntric.com";
			application.developer.phone = "916-776-6650";
			application.currentProgramYear = "2013-2014";
			application.initDateTime = now();
            initValidator();
		</cfscript>
	</cffunction>
	
	<cffunction name="onRequestStart">
	
		<cfif cgi.HTTPS eq "off">
			<cflocation url="https://#cgi.SERVER_NAME##cgi.SCRIPT_NAME#" addtoken="no">
		</cfif>
	
		<cfset request.alerts = ArrayNew(1) />
	
		<cfif IsDefined("initApp")>
			<cflogout />
			<cfscript>
				onApplicationStart();
			</cfscript>
		</cfif>

        <cfif IsDefined("initValidator")>
            <cfscript>
                initValidator();
            </cfscript>
        </cfif>
		
		<cflock scope="application" timeout="20" type="readonly">
			<cfset StructAppend(request, application) />
		</cflock>
		
		<cfif IsDefined("logout")>
			<cflogout />
		</cfif>
	
		<cflogin>
			<cfloginuser name="workshop@user.com" password="password" roles="Workshop" />
		</cflogin>
	
	</cffunction>
	
	<cffunction name="onError">
		<cfargument name="Exception" required="true" />
		<cfargument name="EventName" required="true" />
		<cfif application.mode eq "prod">
			<cfmail to="kenhobbs@gmail.com" from="kenhobbs@gmail.com" subject="Wrapper Error" type="html">
				<cfdump var="#arguments.Exception.Detail#" expand="yes" label="Exception.Detail" />
				<cfdump var="#arguments.Exception.TagContext#" expand="yes" label="Exception.TagContext" />
				<cfdump var="#cgi#" expand="yes" label="CGI" />
				<cfdump var="#form#" expand="yes" label="Form" />
				<cfdump var="#url#" expand="yes" label="URL" />
			</cfmail>
		<cfelse>
			<cfdump var="#arguments.Exception.Detail#" expand="no" label="Exception.Detail" />
			<cfdump var="#arguments.Exception.TagContext#" expand="no" label="Exception.TagContext" />
			<cfdump var="#cgi#" expand="no" label="CGI" />
			<cfdump var="#form#" expand="no" label="Form" />
			<cfdump var="#url#" expand="no" label="URL" />
		</cfif>
		<h1>Ooops</h1>
		<p>The application has encountered an error.  An error message has been sent to the developer.</p>
		<p>If you require immediate assistance with this error, please <a href="mailto:support@syntric.com">contact the developer</a>.</p>
		<cfabort>
	</cffunction>
	
	<cffunction name="onRequestEnd">
        <cfsetting showdebugoutput="no">
    </cffunction>

    <cffunction name="initValidator">
        <cfscript>
            lock scope="application" timeout="20" type="readonly"
            {
                var validatorConfig = {extraRuleValidatorComponentPaths = "/assets/calgrants/com/validators/", definitionPath = "/assets/calgrants/com/bo/"};
                application.validator = new validateThis.ValidateThis(validatorConfig);
            }
        </cfscript>
    </cffunction>

</cfcomponent>

